#include<stdio.h>
int main() {
    int N = 0;
    int x = 0;
    int maxsum = 0;
    int thissum = 0;
    int first, last,last_first;
    first = last =last_first= 0;
    scanf( "%d", &N );
    for( int i = 0; i < N; i++ ) {
        scanf( "%d", &x );
        thissum += x;
        if( thissum > maxsum ) {
            maxsum = thissum;
            last = i;
           first =  last_first;
        }

        if( thissum < 0 ) {
            thissum = 0;
            last_first = i + 1;
        }
    }
    printf( "%d %d %d", maxsum ,first, last);
    return 0;
}